// 字符串还原
import { traverse } from "@babel/core";
import { parse } from "@babel/parser";
import _generate from "@babel/generator";
import fs from "fs";

const code = fs.readFileSync("code2.js", "utf-8");
let ast = parse(code);

traverse(ast, {
    StringLiteral({ node }) {
        if (node.extra && /\\[ux]/gi.test(node.extra.raw)) {
            node.extra.raw = node.extra.rawValue;
        }
    },
});
const { code: output } = _generate.default(ast);
console.log(output);